<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>构造函数的练习</title>
</head>

<body>
    <script>
        // 使用构造函数创建王者荣耀的英雄对象

        function HonorOfKings(uname, utype, ublood) {
            this.yx_name = uname;
            this.yx_type = utype;
            this.yx_blood = ublood;
            this.yx_attack = function(uattack) {
                console.log(uattack);
            }

        }
        var liBai = new HonorOfKings('李白', '刺客', 300);
        console.log(liBai.yx_name);
        console.log(liBai.yx_type);
        liBai.yx_attack('近战');
        console.log(liBai);

        var lianPo = new HonorOfKings('廉颇', '坦克', 1000);
        console.log(lianPo.yx_name);
        console.log(lianPo.yx_type);
        liBai.yx_attack('近战');
    </script>
</body>

</html>